# coding:utf-8



class VLogicString(object):
    """
        用于获取一个ASCII 0-1文件的相关信息
    """
    # 变值信息
    (top,bottom,add,minus) = ([],[],[],[]) 
    p = []
    q = []
    string  = ""

    def loads(self,filepath):
        """
            从文件中载入字符串
        """
        string = open(filepath,"rb").read()
    
    def subsector(self,process_type):
        """
            选择分割机制
        """
        if process_type == 'type1':
            pass
        elif process_type == 'type2':
            pass 




def process_type1(string, offset=1):
    """
        描述：此方法是相关距离来计算top，bottom，add，minus的
        段内循环
        返回坐标x,y
    """
    # top=bottom=add=minus=0
    # str_len =  len(string)
    # for (i, item) in enumerate(string):
    #     if item == '0' and string[(i+offset)%] =''
  


    pass



def process_type2(string):

    """
        描述：此方法是计算相邻两个的状态来计算top，bottom，add，minus的
    """
    pass


def process_nonoverlap(string):
    """
        process_type3--
        此方法是段内1的数目,p的数目，q的数目,非重叠方法
    """
    
    str_len =  len(string)

    # 计算01的数目
    zo_block_counts =  0

    # 计算1的数目
    one_counts = 0
    
    i = 0
    while i < str_len:
        if string[i] == '0' and string[(i+1)%str_len] == '1':
            zo_block_counts += 1
            # 避免在环尾重复计数1
            if i+1<str_len:
                one_counts += 1
            i += 2
        else:
            if string[i] == '1':
                one_counts += 1
            i += 1
    return (one_counts,zo_block_counts)





def process_overlap(string):
    """
        此方法是段内1的数目,p的数目，q的数目,重叠方法
    """
    
    str_len =  len(string)

    # 计算01的数目
    zo_block_counts =  [item for (i, item) in enumerate(string) if item=='0' and string[(i+1)%str_len]=='1' ]
    # 计算1的数目
    one_counts = [item for item in string if item=='1' ]


    return (len(one_counts), len(zo_block_counts))
    
 
def process_type5(string):
    """
        测试用途
    """   
    str_len = len(string)

    zz = 0
    zo = 0
    oz = 0
    oo = 0
    for i in xrange(str_len):
        if string[i] == "0":
            zz += 1
        else:
            zo += 1

    return (zz,zo)


def process_type6(string1,string2):
    d = {"aa":0,"at":0,"ac":0,"ag":0,
         "ta":0,"tt":0,"tc":0,"tg":0,
         "ca":0,"ct":0,"cc":0,"cg":0,
         "ga":0,"gt":0,"gc":0,"gg":0}

    for (a,b) in zip(string1,string2):
        d[a+b] += 1
    return d





def process_xianglinzhuanhuan(string):
    """
        转换成为ATCG
    """
    str_len = len(string)
    result_str = ""
    (zz,oo,zo,oz) = (0,0,0,0,)
    i = 0
    while i<str_len:
        if str_len[2*i:2*i+2] == "00":
            zz += 1
            result_str += "a"
        elif str_len[2*i:2*i+2] == "11":
            oo += 1
            result_str += "t"
        elif str_len[2*i:2*i+2] == "10":
            oz += 1
            result_str += "c"
        elif str_len[2*i:2*i+2] == "01":
            zo += 1
            result_str += "g"

    return result_str





def main():
    test_str = "10101000110"
    print process_type3(test_str)


if __name__ == '__main__':
    main()